package com.botann.projects.base;


/**
 * StorageManager
 * UserDetail 记录登录用户
 * Created by 刘山国 on 2017/5/29.
 * Copyright (c) 2017 刘山国. All rights reserved.
 * if (companyId == null) companyId = UserDetail.current().getCompanyId();
 */

public class UserDetail {

    private UserDetailType type;
    private Integer id;
    //new一个本地线程（静态常量）
    private static final ThreadLocal contexts = new ThreadLocal(); //ThreadLocal，直译为“线程本地”或“本地线程”

    //写一个static的 current()，用于获取登陆者的信息
    public static UserDetail current(){//读取登陆者的信息
        return (UserDetail)contexts.get();
    }

    //加一个UserDetail的构造器 ：无参的，和 全参的
    public UserDetail() {

    }

    public UserDetail(UserDetailType type, Integer id) {
        this.type = type;
        this.id = id;
//        super(u.getId(), u.getUsername(), u.getPassword(), u.getName(), u.getPhone(), u.getRoleId(), u.getCreateTime(), u.isDel());
        contexts.set(this);
    }


    public UserDetailType getType() {
        return type;
    }

    public void setType(UserDetailType type) {
        this.type = type;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
}
